package com.xhwl.logistics.controller;


import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.cent.sdata.Account;
import com.xhwl.common.query.cent.vehicle.CarQuery;
import com.xhwl.common.query.cent.vehicle.OrderQuery;
import com.xhwl.common.query.cent.vehicle.TempParkFeeQuery;
import com.xhwl.common.vo.cent.vehicle.ApplyCarCardVO;
import com.xhwl.common.vo.cent.vehicle.CarPayVo;
import com.xhwl.logistics.service.IVehcCarService;
import com.xhwl.common.vo.cent.vehicle.CarVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lu.Aaron
 * @since 2021-02-08
 * @menu 车辆
 */
//@RestController
@Api(tags = "车辆")
@Slf4j
@RequestMapping("/car")
public class VehcCarController {
    @Autowired
    private IVehcCarService vehcCarService;

    /**
     * 车辆新增
     * @param carVO
     * @param account
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/test/add", method = RequestMethod.POST)
    public ResultJson add(@RequestHeader Short industryId,@RequestBody @Validated CarVO carVO, Account account) {


        return  vehcCarService.add(carVO,account,industryId);
    }

    /**
     * 车辆修改
     * @param carVO
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/test/update", method = RequestMethod.POST)
    public ResultJson update(@RequestHeader Short industryId,@RequestBody @Validated CarVO carVO, Account account) {


        return  vehcCarService.edit(carVO,industryId,account);
    }

    /**
     * 车辆删除
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/test/delete", method = RequestMethod.POST)
    public ResultJson delete(@RequestHeader Short industryId,@RequestParam(value = "id") Integer id) {

        return vehcCarService.delete(id,industryId);

    }
    /**
     * 车辆分页
     * @param carQuery
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/test/page", method = RequestMethod.POST)
    public ResultJson carPage(@RequestBody CarQuery carQuery) {

        return vehcCarService.carPage(carQuery);

    }

    /**
     * 车辆详情
     * @param id
     * @return
     */

    @GetMapping(value = "/test/detail")
    public ResultJson detail(@RequestParam(value = "id") Integer id) {

        return vehcCarService.detail(id);

    }
    /**
     * 我的车辆
     * @return
     */

    @GetMapping(value = "/mine")
    public ResultJson mine(Account account) {

        return vehcCarService.mine(account);

    }

    /**
     * 车辆新增(app)
     * @param carVO
     * @param account
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/test/app-add", method = RequestMethod.POST)
    public ResultJson addFromAPP(@RequestHeader Short industryId,@RequestBody @Validated CarVO carVO, Account account) {


        return  vehcCarService.addFromAPP(carVO,account,industryId);
    }

    /**
     * 申请车卡(app)
     * @param applyCarCardVO
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/test/card-apply", method = RequestMethod.POST)
    public ResultJson cardApply(@RequestBody ApplyCarCardVO applyCarCardVO) {

        return  vehcCarService.cardApply(applyCarCardVO);
    }
    /**
     * 车辆管理(app)
     * @param carQuery
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/test/manage", method = RequestMethod.POST)
    public ResultJson manage(@RequestHeader Short industryId,@RequestBody CarQuery carQuery,Account account) {

        return  vehcCarService.manage(carQuery,account,industryId);
    }

    /**
     * 重新提交（app）
     * @param industryId
     * @param carVO
     * @param account
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/test/resubmit", method = RequestMethod.POST)
    public ResultJson resubmit(@RequestHeader Short industryId,@RequestBody @Validated CarVO carVO, Account account) {

        return  vehcCarService.resubmit(carVO,account,industryId);
    }

    /**
     * 临停缴费费用查询（app）
     * @param industryId
     * @param tempParkFeeQuery
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/test/temp-park-fee-query", method = RequestMethod.POST)
    public ResultJson tempParkFeeQuery(@RequestHeader Short industryId, @RequestBody @Validated TempParkFeeQuery tempParkFeeQuery) {

        return  vehcCarService.tempParkFeeQuery(tempParkFeeQuery,industryId);
    }
    /**
     * 统一下单支付 根据payTypeEnum来选择微信、支付宝。。
     * @param industryId
     * @param carPayVo
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/test/unified-order", method = RequestMethod.POST)
    public ResultJson unifiedOrder(@RequestHeader Short industryId, @RequestBody @Validated CarPayVo carPayVo,Account account) {

        return  vehcCarService.unifiedOrder(carPayVo,industryId,account);
    }
    /**
     * 支付订单状态查询
     * @param industryId
     * @param orderQuery
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/test/pay/order-query", method = RequestMethod.POST)
    public ResultJson orderQuery(@RequestHeader Short industryId, @RequestBody @Validated OrderQuery orderQuery) {

        return  vehcCarService.orderQuery(orderQuery,industryId);
    }
}

